//===================================================
//作    者：边涯  http://www.u3dol.com
//创建时间：2020-08-05 19:19:53
//备    注：
//===================================================
//using YouYouServer.Core;
using System;
using System.Collections.Generic;

/// <summary>
/// 角色数据
/// </summary>
public struct Role_DataProto : IProto
{
    public ushort ProtoCode => 10011;
    public string ProtoEnName => "Role_Data";
    //public ProtoCategory Category => ProtoCategory.Client2WorldServer;

    public int RoleID; //
    public string RoleName; //

    public byte[] ToArray(MMO_MemoryStream ms, bool isChild = false)
    {
        ms.SetLength(0);
        if (!isChild)
        {
            ms.WriteUShort(ProtoCode);
            //ms.WriteByte((byte)Category);
        }

        ms.WriteInt(RoleID);
        ms.WriteUTF8String(RoleName);

        return ms.ToArray();
    }

    public static Role_DataProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        Role_DataProto proto = new Role_DataProto();
        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.RoleID = ms.ReadInt();
        proto.RoleName = ms.ReadUTF8String();

        return proto;
    }
}